<?php
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/config.inc.php');
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/top.inc.php');
?>

<p><a href="../">&lt;&lt; Back to Main Portal</a></p>
<h1>Timeslots</h1>
<p><b>Please select building to view timeslots:</b></p>

<?php

//counting variable
$i = 0;

//select statement
$query="SELECT * FROM buildings";
$result=mysql_query($query);

//close
mysql_close();

//determine dynamically number of rows read from table
$num_rows=mysql_numrows($result);

echo '<p>';

//start table
echo "<table class=\"postSchedule\">";
	
	//create table row with column ID's
	echo "<tr>";
		echo "<td><b>Building Name</b></td>";
		echo "<td></td>";
	echo "</tr>";

//loop to walk through and print to screen all entries in buildings table
$row_count = 0;
while ($i < $num_rows) 
{
	$row_count++;
	//store each building name and abbreviation in a scalar
	$building_id=mysql_result($result,$i,"id");
	$building_name=mysql_result($result,$i,"building_name");
	$abbreviation=mysql_result($result,$i,"abbreviation");
	
	//generate table row for each building on each iteration of the loop
echo "<tr";
	if (($row_count%2) != 0) echo " class=\"zebra_stripe\"";
	echo ">";
		echo "<td>$building_name ($abbreviation)</td>";		//building name cell
		
		echo "<td>";		//cell containing form for update timeslots link/button
			echo "<a href='timeslots.php?id=$building_id'>Update Timeslots</a>";
		echo "</td>";
	echo "</tr>";
		
	//increment counting variable
	$i++;
}

//end table tag
echo "</table>";


?>


<?php
	require_once($_SERVER['DOCUMENT_ROOT'].'uno-course-scheduler/include/bottom.inc.php');
?>